    let context = $("#lineChart").get(0).getContext('2d');
    let chartData = $('#data').data('chart_data')
    let chart
    chart = new Chart(context, {
        type: 'bar',
        data: {
            labels: chartData.labels,
            datasets: [
                {
                    label: "Новых пользователей",
                    data: chartData.registrationsCount,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(54, 162, 235, 0.5)",
                    borderColor: "rgb(54, 162, 235)",
                    borderWidth: 1.2
                },
				{
                    label: "Добавлено аккаунтов",
                    data: chartData.accounts_added,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(104, 107, 255, 0.5)",
                    borderColor: "rgb(104, 107, 255)",
                    borderWidth: 1.2
                },
				{
                    label: "Лайков",
                    data: chartData.likes,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(160, 64, 255, 0.5)",
                    borderColor: "rgb(160, 64, 255)",
                    borderWidth: 1.2
                },
				{
                    label: "Комментариев",
                    data: chartData.comments,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(48, 198, 124, 0.5)",
                    borderColor: "rgb(48, 198, 124)",
                    borderWidth: 1.2
                },
				{
                    label: "Документов",
                    data: chartData.documents,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(242,146,237, 0.5)",
                    borderColor: "rgb(242,146,237)",
                    borderWidth: 1.2
                },
				{
                    label: "Креативов",
                    data: chartData.unique,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(228,233,93, 0.5)",
                    borderColor: "rgb(228,233,93)",
                    borderWidth: 1.2
                },
				{
                    label: "Вайтпейджей",
                    data: chartData.whitepages,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(255, 51, 51, 0.5)",
                    borderColor: "rgb(255, 51, 51)",
                    borderWidth: 1.2
                },
                {
                    label: "Dolphin аккаунтов",
                    data: chartData.dolphin_accs,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(26, 140, 206, 0.5)",
                    borderColor: "rgb(26, 140, 206)",
                    borderWidth: 1.2
                },
                {
                    label: "WLO аккаунтов",
                    data: chartData.wlo_accs,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(0, 100, 206, 0.5)",
                    borderColor: "rgb(0, 100, 206)",
                    borderWidth: 1.2
                },
                {
                    label: "Рассылка",
                    data: chartData.messages_distribution,
                    fill: true,
                    lineTension: 0.2,
                    backgroundColor: "rgba(255, 155, 4, 0.5)",
                    borderColor: "rgb(255, 155, 4)",
                    borderWidth: 1.2
                },
            ]
        },
        options: {
            responsive: true
        },
    })

    $("#changeDateButton").click(() => {
        let data = {date_from: $('#datefrom').val(), date_to: $('#dateto').val()};
        var chart_data = $.post("/admin", data)
        chart_data.done(function(chartData) {
            console.log(chartData)
			chartData = JSON.parse(chartData)
			chart.data.labels = chartData.labels
			chart.data.datasets[0].data = chartData.registrationsCount
			chart.data.datasets[1].data = chartData.accounts_added
			chart.data.datasets[2].data = chartData.likes
			chart.data.datasets[3].data = chartData.comments
			chart.data.datasets[4].data = chartData.documents
			chart.data.datasets[5].data = chartData.unique
			chart.data.datasets[6].data = chartData.whitepages
            chart.data.datasets[7].data = chartData.dolphin_accs
            chart.data.datasets[8].data = chartData.wlo_accs
            chart.data.datasets[9].data = chartData.messages_distribution
            chart.update();
        });
    });

